*This file replicates regression results for Investment and Employment outcomes. 
*The code used in this file is adapted from Baker, Bloom, and Davis (2016) to generate results related to environmental policy uncertainty.

cap cd "panel_regressions"
clear all
use data/all_firm_data_updated
set more off

so gvkey year quarter
merge 1:1 gvkey year quarter using data/tobin_q_data, keepus(tobin_q) 
ren tobin_q tobin
drop if _m==2  
drop _m
so gvkey year quarter
merge 1:1 gvkey year quarter using data/cashflow_data, keepus(cashflow)
tab _m
drop if _m==2
drop _m

merge m:1 year quarter using data/modern_epu_quarterly 

foreach var in E P U EP EU PU EPU {
	gen lm_`var'=log(m_`var')
}
drop if _merge==2
drop _merge
merge m:1 year quarter using data/categories_yq //
gen yq=year+(quarter-1)/4
gen lepu=log(m_EPU)
gen leu=log(m_EU)

********************Updating/Fixing VIX
cap drop _merge
ren vix oldvix
so yq
merge m:1 yq using data/vix.dta,update
replace lvix=log(vix)
drop _m
merge m:1 yq using data/vxo_quarterly.dta,update
drop _m
*replace vix with vxo
replace vix=vxo if vix==.&vxo~=.
replace lvix=log(vix)

***************Add in Steve's intensity measure
so gvkey
merg m:1 gvkey using data/gvkey
drop if _m==2
drop _m
so cusip
*merge cusip using data/steve_data_xs
merge m:1 cusip using data/steve10k_cusip
winsor2 jp,replace 

drop if _m==2
drop _m
ren jp jp 

*merge data relevant to Environmental Policy Uncertainty
merge m:1 gvkey using data/gv_key_state
drop _m
merge m:1 year quarter using data/04_Env_Policy_indices_qtr
drop _m
merge m:1 year quarter using data/12_EPU_EPAregions_Quarter
drop _m
merge m:1 year quarter using data/13_EP_EPAregions_Quarter
drop _m
drop if gvkey ==.
merge m:m gvkey using data/gv_key_state
drop _m
drop if year==.

*Generates EPA region specific measure of Environmental Policy Uncertainty
foreach var in PU P {
gen E`var'_EPAreg2 = E`var'_NB_local
replace E`var'_EPAreg2 = Env`var'_EPA_1_2 if inlist(state, "VT", "NH", "ME", "MA", "RI", "CT", "NJ", "NY")
replace E`var'_EPAreg2 = Env`var'_EPA_3_4 if inlist(state, "DE", "MD", "PA" , "VA", "WV")
replace E`var'_EPAreg2 = Env`var'_EPA_3_4 if inlist(state, "AL" , "FL" , "GA" , "KY" , "MS" , "NC" , "SC" , "TN")
replace E`var'_EPAreg2 = Env`var'_EPA_5_7 if inlist(state, "IL" , "IN" , "MI" , "MN" , "OH" , "WI") 
replace E`var'_EPAreg2 = Env`var'_EPA_5_7 if inlist(state, "IA" , "KS" , "MO" , "NE")
replace E`var'_EPAreg2 = Env`var'_EPA_6_8 if inlist(state, "AR", "LA" , "NM" , "OK" , "TX" ) 
replace E`var'_EPAreg2 = Env`var'_EPA_6_8 if inlist(state, "CO" , "MT" , "ND" , "SD" , "UT" , "WY")
replace E`var'_EPAreg2 = Env`var'_EPA_9_10 if inlist(state, "AZ" , "CA" , "HI" , "NV", "AK" , "ID" , "OR" , "WA")
}
*
************************************************************************************************************************
***Here we make all of the necessary interactions for each intensity measure
************************************************************************************************************************
tsset ticker_code period_code

foreach var of varlist h_firm_sic_intens  {
	foreach var2 of varlist m_* lm_* vix lepu lvix fed fed_fore leu {
		qui gen `var2'_X_`var' = `var2'*`var'
		qui gen l1`var2'_X_`var' = l1.`var2'_X_`var'
		qui gen dl1`var2'_X_`var' = d.l1`var2'_X_`var'
	}
}

foreach var of varlist firm_intens sic_intens firm_sic_intens belo_intens jp {
	foreach var2 of varlist lepu fed {
		qui gen `var2'_X_`var' = `var2'*`var'
		qui gen l1`var2'_X_`var' = l1.`var2'_X_`var'
		qui gen dl1`var2'_X_`var' = d.l1`var2'_X_`var'
	}
}
gen lagppent=l.ppent

gen l1lepu=l1.lepu
gen dl1lepu=d.l1lepu
gen l1fed=l1.fed
gen dl1fed=d.l1fed
gen SIC2=int(sic4/100)

gen env_firms=1 if inlist(sic3, 104, 109, 122, 131, 138, 241, 242, 491, 492) | inlist(SIC2, 1, 2, 37)
replace env_firms=0 if env_firms==.

foreach var in EPU_Factiva EP_Factiva EPU_NB EP_NB EPU_NB_local EP_NB_local EPU_EPAreg2 EP_EPAreg2{
replace `var'=0 if env_firms==0
}
*
merge m:1 year quarter using data/A - DP_FP_HP_Quarter
drop _m

*
gen def_firms = inlist(sic3, 348, 381, 871) //inlist(sic3, 348, 372, 376, 379, 381, 871)
foreach var in defense dp dpu {
replace `var'=0 if def_firms==0
}

gen health_firms=(sic3>=800&sic3<=809)
foreach var in health hp hpu{
replace `var'=0 if health_firms==0
}

gen fin_firms= (sic3>=600&sic3<=679) 
foreach var in fin_regulation fp fpu{
replace `var'=0 if fin_firms==0
}

tsset ticker_code period_code

foreach var in EPU_Factiva EP_Factiva EPU_NB EP_NB EPU_NB_local EP_NB_local EPU_EPAreg2 EP_EPAreg2 defense health fin_regulation dp dpu hp hpu fp fpu{
gen l`var'=log(`var')
gen dl`var'=d.l`var'
gen dl`var'_miss=(dl`var'==.)
replace dl`var'=0 if dl`var'_miss==1
}
merge m:1 year using data/14 - year_DividedGovt
ren ( DividedGovDeffinition1 DividedGovDeffinition2 ) (div1 div2)



*******for repub vs democratic senate terms
gen repub=1 if (year>1980 & year<1987)|(year>1994 & year<2001)|(year>2002 & year<2007)|(year>2014)
replace repub=0 if repub==.
gen repub_presi= (year>=1981 & year<1993) | (year>=2001 & year<2009) | (year>=2017 & year<2021) 

tsset ticker_code period_code
foreach var in lEPU_Factiva lEP_Factiva lEPU_NB lEP_NB lEPU_NB_local lEP_NB_local ldefense lhealth lfin_regulation ldp ldpu lhp lhpu lfp lfpu{
gen `var'Xrepub=`var'*repub
gen d`var'Xrepub=d.`var'Xrepub
gen d`var'Xrepub_miss=(d`var'Xrepub==.)
replace d`var'Xrepub=0 if d`var'Xrepub_miss==1
}

foreach var in lEPU_Factiva lEP_Factiva lEPU_NB lEP_NB lEPU_NB_local lEP_NB_local ldefense lhealth lfin_regulation ldp ldpu lhp lhpu lfp lfpu{
gen `var'Xrpresi=`var'*repub_presi
gen d`var'Xrpresi=d.`var'Xrpresi
gen d`var'Xrpresi_miss=(d`var'Xrpresi==.)
replace d`var'Xrpresi=0 if d`var'Xrpresi_miss==1
}

foreach var in lEPU_Factiva lEP_Factiva lEPU_NB lEP_NB lEPU_NB_local lEP_NB_local ldefense lhealth lfin_regulation ldp ldpu lhp lhpu lfp lfpu{
foreach y in div1 div2{
gen `var'X`y'=`var'*`y'
gen d`var'X`y'=d.`var'X`y'
gen d`var'X`y'_miss=(d`var'X`y'==.)
replace d`var'X`y'=0 if d`var'X`y'_miss==1
}
}
********************************************************************************
label var iqr_fed_gov_forecast "Fed Exp. IQR"

***Compress
drop nom_fed_exp nom_gdp  vxo lvxo iqr_fed_gov_forecast ticker
egen avg_emp = mean(emp), by(ticker_code)
replace avg_emp=round(1000*avg_emp)

*Note: reghdfe can't weight with non-integer values so scale by 1000 and round, plus enforce all firms to have 1+ employee
replace avg_emp=1 if avg_emp==0
egen mavg_emp=mean(avg_emp)
replace avg_emp=round(mavg_emp) if avg_emp==.
egen min_year = min(year), by(ticker_code )
gen age = year-min_year
drop *long obligatedamount atq xrd iq lrevtq firm_cap_intens firm_rd_intens sic2 
compress

gen inv_rate = capxy / l.ppentq

gen sizeemp=emp
replace sizeemp=round(1000*sizeemp)

save data/itemp,replace
cap log close
cap log using invemp,replace t

tsset
gen logemp=log(sizeemp)
gen llogemp=l.logemp
drop logemp
ren llogemp logemp

gen lrevtq = log(revtq)
gen llrevtq = l.lrevtq
drop lrevtq
ren llrevtq lrevtq
foreach var in lEPU_Factiva lEP_Factiva lEPU_NB lEP_NB lEPU_NB_local lEP_NB_local ldefense lhealth lfin_regulation ldp ldpu lhp lhpu lfp lfpu{
foreach y in lrevtq logemp{
gen `var'_X_`y'= `var'*`y'
gen d`var'_X_`y'=d.`var'_X_`y'
gen d`var'_X_`y'_miss=(d`var'_X_`y'==.)
replace d`var'_X_`y'=0 if d`var'_X_`y'_miss==1
}
}
gen mining = ((sic3>=101 & sic3<=109) | sic3==122 | sic3==123 | sic3==124)
gen utilities = (sic3==491 | sic3==492)
gen agri = (SIC2==1 | SIC2==2 | sic3==241 | sic3==242)
gen vehicle = (SIC2==37)
gen oilgas = (sic3>=131 & sic3<=138)

foreach var in lEPU_Factiva lEP_Factiva lEPU_NB lEP_NB lEPU_NB_local lEP_NB_local ldp ldpu lhp lhpu lfp lfpu{
foreach sec in mining utilities agri oilgas{
gen `var'_X_`sec'= `var'*`sec'
gen d`var'_X_`sec'= d.`var'_X_`sec'
gen d`var'_X_`sec'_miss=(d`var'_X_`sec'==.)
replace d`var'_X_`sec'=0 if d`var'_X_`sec'_miss==1
}
}

foreach var in lrevtq logemp{
gen d`var' = d.`var'
gen d`var'_miss = (`var'==.)
replace d`var' = 0 if d`var'_miss==1
}


**********REGRESSIONS*******************************************************************

******* With PUs and Ps (Table 5)
reghdfe invest_ppe_rate dlEPU_NB dlEP_NB dldpu dldp dlhpu dlhp dlfpu dlfp dl1lepu_X_h_firm_sic_intens dl1fed_X_h_firm_sic_intens,  ab(ticker_code period_code) vce(cl ticker)

******* Original only with PUs (Table A3)
reghdfe invest_ppe_rate dlEPU_NB dldpu dlhpu dlfpu dl1lepu_X_h_firm_sic_intens dl1fed_X_h_firm_sic_intens,  ab(ticker_code period_code) vce(cl ticker)

******** heterogeneity: Firm size (Table 6 and A7)
reghdfe invest_ppe_rate dlEPU_NB_X_lrevtq dlEPU_NB dlEP_NB_X_lrevtq dlEP_NB dldpu_X_lrevtq dldpu dldp_X_lrevtq dldp dlhpu_X_lrevtq dlhpu dlhp_X_lrevtq dlhp dlfpu_X_lrevtq dlfpu dlfp_X_lrevtq dlfp dlrevtq dl1lepu_X_h_firm_sic_intens dl1fed_X_h_firm_sic_intens, ab(ticker_code period_code) vce(cl ticker)
reghdfe invest_ppe_rate dlEPU_NB_X_logemp dlEPU_NB dlEP_NB_X_logemp dlEP_NB dldpu_X_logemp dldpu dldp_X_logemp dldp dlhpu_X_logemp dlhpu dlhp_X_logemp dlhp dlfpu_X_logemp dlfpu dlfp_X_logemp dlfp dlogemp dl1lepu_X_h_firm_sic_intens dl1fed_X_h_firm_sic_intens, ab(ticker_code period_code) vce(cl ticker)

******** heterogeneity: Political party (Tables 7, A9, and 8)
reghdfe invest_ppe_rate dlEPU_NBXrpresi dlEPU_NB dlEP_NBXrpresi dlEP_NB dldpuXrpresi dldpu dldpXrpresi dldp dlhpuXrpresi dlhpu dlhpXrpresi dlhp dlfpuXrpresi dlfpu dlfpXrpresi dlfp repub_presi dl1lepu_X_h_firm_sic_intens dl1fed_X_h_firm_sic_intens, ab(ticker_code period_code) vce(cl ticker)

reghdfe invest_ppe_rate dlEPU_NBXrepub dlEPU_NB dlEP_NBXrepub dlEP_NB dldpuXrepub dldpu dldpXrepub dldp dlhpuXrepub dlhpu dlhpXrepub dlhp dlfpuXrepub dlfpu dlfpXrepub dlfp repub dl1lepu_X_h_firm_sic_intens dl1fed_X_h_firm_sic_intens, ab(ticker_code period_code) vce(cl ticker)

reghdfe invest_ppe_rate dlEPU_NBXdiv2 dlEPU_NB dlEP_NBXdiv2 dlEP_NB dldpuXdiv2 dldpu dldpXdiv2 dldp dlhpuXdiv2 dlhpu dlhpXdiv2 dlhp dlfpuXdiv2 dlfpu dlfpXdiv2 dlfp div2 dl1lepu_X_h_firm_sic_intens dl1fed_X_h_firm_sic_intens, ab(ticker_code period_code) vce(cl ticker)

******** heterogeneity: Firm sector  results (Table A8)
reghdfe invest_ppe_rate dlEPU_NB_X_mining dlEPU_NB_X_utilities dlEPU_NB_X_agri dlEPU_NB_X_oilgas dlEPU_NB dlEP_NB_X_mining dlEP_NB_X_utilities dlEP_NB_X_agri dlEP_NB_X_oilgas dlEP_NB dldpu dldp dlhpu dlhp dlfpu dlfp dl1lepu_X_h_firm_sic_intens dl1fed_X_h_firm_sic_intens, ab(ticker_code period_code) vce(cl ticker)

********** Local EnvPU effect using EPA region clusters as local (Table A10)
reghdfe invest_ppe_rate dlEPU_EPAreg2 dlEP_EPAreg2 dldpu dldp dlhpu dlhp dlfpu dlfp dl1lepu_X_h_firm_sic_intens dl1fed_X_h_firm_sic_intens if year>=1990,  ab(ticker_code period_code) vce(cl ticker)

********** National EnvPU effect (Table A11)
reghdfe invest_ppe_rate dlEPU_Factiva dlEP_Factiva dldpu dldp dlhpu dlhp dlfpu dlfp dl1lepu_X_h_firm_sic_intens dl1fed_X_h_firm_sic_intens,  ab(ticker_code period_code) vce(cl ticker)

******** Local and national news effect on firm performance (Table A12)
reghdfe invest_ppe_rate dlEPU_Factiva dlEP_Factiva dlEPU_EPAreg2 dlEP_EPAreg2 dldpu dldp dlhpu dlhp dlfpu dlfp dl1lepu_X_h_firm_sic_intens dl1fed_X_h_firm_sic_intens if year>=1990,  ab(ticker_code period_code) vce(cl ticker)


************************************************************************
*For summary statistics (Table 3)
qui reghdfe invest_ppe_rate dlEPU_NB dldpu dlhpu dlfpu dl1lepu_X_h_firm_sic_intens dl1fed_X_h_firm_sic_intens,  ab(ticker_code period_code) vce(cl ticker)
keep if e(sample)
estpost sum invest_ppe_rate
estpost sum invest_ppe_rate if env_firms==1
estpost sum invest_ppe_rate if def_firms  ==1
estpost sum invest_ppe_rate if health_firms==1
estpost sum invest_ppe_rate if fin_firms==1


************************************************************************************************************************************************************************
************************************************************************************
***************EMPLOYMENT
***Collapse to yearly data
clear all
use data/annual_firm_data 
gen period_code=year
tsset ticker_code period_code
gen one=1

foreach var of varlist one firm_intens sic_intens firm_sic_intens health_sic_intens health_firm_intens belo_intens h_firm_sic_intens {
	foreach var2 of varlist lepu leu lvix fed  fed_fore {
		qui gen `var2'_X_`var' = `var2'*`var'
		qui gen d`var2'_X_`var' = d.`var2'_X_`var'
	}
}

tsset 
gen demp = (emp - l.emp)/(0.5*emp+0.5*l.emp)
gen drev = (revtq - l.revtq)/(0.5*revtq+0.5*l.revtq)
replace drev = . if drev>=2 |drev<=-2

gen dlepu = d.lepu
gen dh_firm_sic_intens =d.h_firm_sic_intens
gen dfed = d.fed

gen SIC2=int(sic4/100)

merge m:1 year using data/04_Env_Policy_indices_annual
drop _m
merge m:1 ticker using data/07 - Ticker_Gvkey_State
drop _m
merge m:1 year using data/12_EPU_EPAregions_Year
drop _m
merge m:1 year using data/13_EP_EPAregions_Year
drop _m
drop if ticker==.
drop if year==.

foreach var in PU P {
gen E`var'_EPAreg2 = E`var'_NB_local
replace E`var'_EPAreg2 = Env`var'_EPA_1_2 if inlist(state, "VT", "NH", "ME", "MA", "RI", "CT", "NJ", "NY")
replace E`var'_EPAreg2 = Env`var'_EPA_3_4 if inlist(state, "DE", "MD", "PA" , "VA", "WV")
replace E`var'_EPAreg2 = Env`var'_EPA_3_4 if inlist(state, "AL" , "FL" , "GA" , "KY" , "MS" , "NC" , "SC" , "TN")
replace E`var'_EPAreg2 = Env`var'_EPA_5_7 if inlist(state, "IL" , "IN" , "MI" , "MN" , "OH" , "WI") 
replace E`var'_EPAreg2 = Env`var'_EPA_5_7 if inlist(state, "IA" , "KS" , "MO" , "NE")
replace E`var'_EPAreg2 = Env`var'_EPA_6_8 if inlist(state, "AR", "LA" , "NM" , "OK" , "TX" ) 
replace E`var'_EPAreg2 = Env`var'_EPA_6_8 if inlist(state, "CO" , "MT" , "ND" , "SD" , "UT" , "WY")
replace E`var'_EPAreg2 = Env`var'_EPA_9_10 if inlist(state, "AZ" , "CA" , "HI" , "NV", "AK" , "ID" , "OR" , "WA")
}
*
tsset

* Sectoral policy indices
gen env_firms=1 if inlist(sic3, 104, 109, 122, 131, 138, 241, 242, 491, 492) | inlist(SIC2, 1, 2, 37)
replace env_firms=0 if env_firms==.

*Change to mfg_firms for robustness
foreach var in EPU_Factiva EP_Factiva EPU_NB EP_NB EPU_NB_local EP_NB_local EPU_EPAreg2 EP_EPAreg2{
replace `var'=0 if env_firms==0
}
*
merge m:1 year using data/A - DP_FP_HP_Year
drop _m
*
gen def_firms = inlist(sic3, 348, 381, 871) 
foreach var in defense dp dpu {
replace `var'=0 if def_firms==0
}

gen health_firms=(sic3>=800&sic3<=809)
foreach var in health hp hpu{
replace `var'=0 if health_firms==0
}

gen fin_firms= (sic3>=600&sic3<=679) 
foreach var in fin_regulation fp fpu{
replace `var'=0 if fin_firms==0
}

tsset ticker_code period_code

foreach var in defense EPU_Factiva EP_Factiva EPU_NB EP_NB EPU_NB_local EP_NB_local EPU_EPAreg2 EP_EPAreg2 health fin_regulation dp dpu hp hpu fp fpu {
gen l`var'=log(`var')
gen dl`var'=d.l`var'
gen dl`var'_miss=(dl`var'==.)
replace dl`var'=0 if dl`var'_miss==1
}

egen noj=count(demp),by(ticker_code)
keep if noj>1

gen repub= (year>1980 & year<1987)|(year>1994 & year<2001)|(year>2002 & year<2007)|(year>2014)
gen repub_presi= (year>=1981 & year<1993) | (year>=2001 & year<2009) | (year>=2017 & year<2021) 
merge m:1 year using data/14 - year_DividedGovt
ren ( DividedGovDeffinition1 DividedGovDeffinition2 ) (div1 div2)

tsset ticker_code period_code
gen lrevtq = log(revtq)

foreach var in lEPU_Factiva lEPU_NB lEPU_NB_local lEP_Factiva lEP_NB lEP_NB_local ldefense lhealth lfin_regulation ldp ldpu lhp lhpu lfp lfpu{
foreach y in lrevtq repub{
gen `var'X`y'=`var'*`y'
gen d`var'X`y'=d.`var'X`y'
gen d`var'X`y'_miss=(d`var'X`y'==.)
replace d`var'X`y'=0 if d`var'X`y'_miss==1
}
}
foreach var in lEPU_Factiva lEPU_NB lEPU_NB_local lEP_Factiva lEP_NB lEP_NB_local ldefense lhealth lfin_regulation ldp ldpu lhp lhpu lfp lfpu{
gen `var'Xrpresi=`var'*repub_presi
gen d`var'Xrpresi=d.`var'Xrpresi
gen d`var'Xrpresi_miss=(d`var'Xrpresi==.)
replace d`var'Xrpresi=0 if d`var'Xrpresi_miss==1
}
foreach var in lEPU_Factiva lEPU_NB lEPU_NB_local lEP_Factiva lEP_NB lEP_NB_local ldefense lhealth lfin_regulation ldp ldpu lhp lhpu lfp lfpu{
foreach y in div1 div2{
gen `var'X`y'=`var'*`y'
gen d`var'X`y'=d.`var'X`y'
gen d`var'X`y'_miss=(d`var'X`y'==.)
replace d`var'X`y'=0 if d`var'X`y'_miss==1
}
}
*
foreach var in lrevtq{
gen d`var' = d.`var'
gen d`var'_miss = (`var'==.)
replace d`var' = 0 if d`var'_miss==1
}

*Generate industry-wise employment
egen avg_emp = mean(emp), by(ticker_code)

**********REGRESSIONS*******************************************************************

qui reghdfe dlepu_X_h_firm_sic_intens dfed_X_h_firm_sic_intens  dfed_fore_X_h_firm_sic_intens dldefense dlhealth dlfin_regulation, ab(ticker_code period_code) 
save data/etemp,replace

******** with PUs and Ps (Table 5)
reghdfe demp dlEPU_NB dlEP_NB dldpu dldp dlhpu dlhp dlfpu dlfp dlepu_X_h_firm_sic_intens dfed_X_h_firm_sic_intens, ab(ticker_code period_code) vce(cl ticker)

******** Original only with PUs (Table A3)
reghdfe demp dlEPU_NB dldpu dlhpu dlfpu dlepu_X_h_firm_sic_intens dfed_X_h_firm_sic_intens, ab(ticker_code period_code) vce(cl ticker)

********* heterogeneity: Firm size (Table 6)
reghdfe demp dlEPU_NBXlrevtq dlEPU_NB dlEP_NBXlrevtq dlEP_NB dldpuXlrevtq dldpu dldpXlrevtq dldp dlhpuXlrevtq dlhpu dlhpXlrevtq dlhp dlfpuXlrevtq dlfpu dlfpXlrevtq dlfp dlrevtq dlepu_X_h_firm_sic_intens dfed_X_h_firm_sic_intens, ab(ticker_code period_code) vce(cl ticker)

******** heterogeneity: Political party (Table 7, A9, and 8)
reghdfe demp dlEPU_NBXrpresi dlEPU_NB dlEP_NBXrpresi dlEP_NB dldpuXrpresi dldpu dldpXrpresi dldp dlhpuXrpresi dlhpu dlhpXrpresi dlhp dlfpuXrpresi dlfpu dlfpXrpresi dlfp repub_presi dlepu_X_h_firm_sic_intens dfed_X_h_firm_sic_intens, ab(ticker_code period_code) vce(cl ticker)
reghdfe demp dlEPU_NBXrepub dlEPU_NB dlEP_NBXrepub dlEP_NB dldpuXrepub dldpu dldpXrepub dldp dlhpuXrepub dlhpu dlhpXrepub dlhp dlfpuXrepub dlfpu dlfpXrepub dlfp repub dlepu_X_h_firm_sic_intens dfed_X_h_firm_sic_intens, ab(ticker_code period_code) vce(cl ticker)
reghdfe demp dlEPU_NBXdiv2 dlEPU_NB dlEP_NBXdiv2 dlEP_NB dldpuXdiv2 dldpu dldpXdiv2 dldp dlhpuXdiv2 dlhpu dlhpXdiv2 dlhp dlfpuXdiv2 dlfpu dlfpXdiv2 dlfp div2 dlepu_X_h_firm_sic_intens dfed_X_h_firm_sic_intens, ab(ticker_code period_code) vce(cl ticker)

******* Local EnvPU effect using EPA region clusters as local (Table A10)
reghdfe demp dlEPU_EPAreg2 dlEP_EPAreg2 dldpu dldp dlhpu dlhp dlfpu dlfp dlepu_X_h_firm_sic_intens dfed_X_h_firm_sic_intens if year>=1990, ab(ticker_code period_code) vce(cl ticker)

******* National EnvPU effect (Table A11)
reghdfe demp dlEPU_Factiva dlEP_Factiva dldpu dldp dlhpu dlhp dlfpu dlfp dlepu_X_h_firm_sic_intens dfed_X_h_firm_sic_intens, ab(ticker_code period_code) vce(cl ticker)

******** Local and national news effect on firm performance (Table A12)
reghdfe demp dlEPU_Factiva dlEP_Factiva dlEPU_EPAreg2 dlEP_EPAreg2 dldpu dldp dlhpu dlhp dlfpu dlfp dlepu_X_h_firm_sic_intens dfed_X_h_firm_sic_intens if year>=1990, ab(ticker_code period_code) vce(cl ticker)

******** For summary statistics (Table 3)
qui reghdfe demp dlEPU_NB dldpu dlhpu dlfpu dlepu_X_h_firm_sic_intens dfed_X_h_firm_sic_intens, ab(ticker_code period_code) vce(cl ticker)
keep if e(sample)
estpost sum demp
estpost sum demp if env_firms==1
estpost sum demp if def_firms  ==1
estpost sum demp if health_firms==1
estpost sum demp if fin_firms==1
log close

****************************************************************************************
